<?php
/**
 * ===============================================
 * 版权所有 2019-2050 青岛铁锤科技有限公司，并保留所有权利。
 * 网站地址: http://www.huaxianling.com
 * ===============================================
 * Author: Happy dong
 * Created Time: 2019-08-09 15:28
 *
 * Version: 2.0
 */

namespace App\Modules\Employee\Criterias;


use Flower\Core\Repository\Contracts\RepositoryInterface;
use Flower\Core\Repository\Criterias\BaseCriterias;

class GetDynamicListCriteria extends BaseCriterias
{

    private $userIds;
    private $store_id;
	public function __construct($userIds,$store_id)
	{
        $this->userIds = $userIds;
        $this->store_id = $store_id;
	}


	public function apply($model, RepositoryInterface $repository)
	{
	    $store_id = $this->store_id;
		$userIds = is_array($this->userIds) ? $this->userIds : [$this->userIds];
		return $model->with('resource')
			->whereIn('user_id',$userIds)
            ->where('store_id',$store_id)
			->orderBy('id','desc');
	}
}